package com.news.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/validateCode.do")
public class ValidateCodeController extends HttpServlet{
	private static final long serialVersionUID = 374594007109945992L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//用户提交
		String code = req.getParameter("code");
		//session中的
		String session_code = (String) req.getSession().getAttribute("session_code");
		//进行对比验证
		if(code.equalsIgnoreCase(session_code)){
			resp.getWriter().write("t");
		}else{
			resp.getWriter().write("f");
		}
	}
	
}
